var t = getApp();

Page({
    data: {
        list_show: !1,
        arrow_active: 0,
        lock: !0,
        city: "地市",
        year: "年份",
        unit: "机关单位",
        scrollHeight: wx.getSystemInfoSync().windowHeight - 130,
        clientHeight: wx.getSystemInfoSync().windowHeight - 150,
        shadow: !1,
        showCity: !1,
        showYear: !1,
        showUnit: !1,
        cityList: [ "北京", "北京", "北京" ],
        yearList: [ 2020, 2019 ],
        unitList: [ "单位1", "单位2", "单位3" ],
        cityIndex: null,
        yearIndex: null,
        unitIndex: null,
        city_list01: [ "安徽", "北京", "重庆", "福建", "广东", "广西", "贵州", "甘肃", "河北", "河南", "湖北", "湖南", "黑龙江", "海南", "吉林", "江苏", "江西", "辽宁", "宁夏", "内蒙古", "青海", "上海", "四川", "山东", "山西", "陕西", "天津", "新疆", "西藏", "云南", "浙江" ],
        city_list02: [],
        zwk_fenlei: "",
        zwk_yrsj: "",
        keyword: "",
        xueli: "",
        xuewei: "",
        zwk_bmmc: "",
        list: [],
        zwk_sheng: "",
        no_num: 0,
        jgdw_province: "",
        jgdw_city: "",
        collectNum: 0
    },
    onLoad: function(t) {
        var e = this;
        this.chooseJob01(), wx.createSelectorQuery().select(".linkage_scroll").boundingClientRect(function(t) {
            e.setData({
                cityHeight: 330
            });
        }).exec(), wx.createSelectorQuery().select(".nav_year").boundingClientRect(function(t) {
            e.setData({
                yearHeight: 160
            });
        }).exec(), wx.createSelectorQuery().select(".slide_list").boundingClientRect(function(t) {
            e.setData({
                unitHeight: t.height
            });
        }).exec(), e.getList(), wx.getStorageSync("collectNum") && e.setData({
            collectNum: wx.getStorageSync("collectNum")
        });
    },
    getCity01: function(e) {
        var a = this, i = (e.currentTarget.dataset.index, e.currentTarget.dataset.val);
        console.log(i), a.setData({
            zwk_sheng: i,
            jgdw_province: i
        }), wx.request({
            url: t.globalData.request_url + "api/zhiweiku/gk/getSelect.php",
            method: "POST",
            data: {
                act: "getDidqu",
                zwk_sheng: i
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                if (200 == t.data.code) {
                    for (var e = [], i = 0; i < t.data.data.length; i++) e.push(t.data.data[i]);
                    a.setData({
                        city_list02: e
                    });
                }
            }
        });
    },
    getCity02: function(t) {
        var e = t.currentTarget.dataset.val;
        t.currentTarget.dataset.index;
        this.setData({
            city: e,
            jgdw_city: e
        }), this.setData({
            showCity: !1,
            showYear: !1,
            showUnit: !1,
            shadow: !1
        });
        var a = this;
        a.getList(), a.chooseJob01();
    },
    getList: function() {
        this.data.success && wx.showLoading({
            title: "加载中"
        });
        var e = this, a = e.data.year;
        a = 2019 == a ? "lastyear" : "nowyear";
        var i = e.data.zwk_sheng, s = e.data.city;
        "地市" == s && (s = "");
        var o = e.data.zwk_fenlei, n = e.data.zwk_bmmc, c = e.data.zwk_yrsj;
        wx.request({
            url: t.globalData.request_url + "api/zhiweiku/gk/getNone.php",
            method: "POST",
            data: {
                act: "getMsg",
                zwk_sheng: i,
                zwk_diqu: s,
                search_year: a,
                zwk_fenlei: o,
                zwk_bmmc: n,
                zwk_yrsj: c,
                openid: wx.getStorageSync("openId")
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                200 == t.data.code && (t.data.data.length > 0 ? e.setData({
                    list: t.data.data,
                    no_num: t.data.extra.total
                }) : e.setData({
                    list: [],
                    no_num: 0
                }), e.data.success && wx.hideLoading(), e.setData({
                    success: !0
                }));
            }
        });
    },
    slide: function(t) {
        var e = t.currentTarget.dataset.index;
        if (e == this.data.arrow_active) this.setData({
            arrow_active: null
        }); else {
            var a = this.data.list_show;
            a = !a, this.setData({
                list_show: a,
                arrow_active: e
            });
        }
    },
    bindCity: function() {
        if (this.data.showCity) return this.setData({
            showCity: !1,
            shadow: !1,
            showYear: !1,
            showUnit: !1
        }), !1;
        this.setData({
            shadow: !0,
            showCity: !0,
            showYear: !1,
            showUnit: !1
        });
    },
    choose_city: function(t) {
        var e = t.currentTarget.dataset.text, a = t.currentTarget.dataset.index;
        this.setData({
            showCity: !1,
            showYear: !1,
            showUnit: !1,
            shadow: !1,
            city: e,
            cityIndex: a
        });
    },
    bindYear: function() {
        if (this.data.showYear) return this.setData({
            showCity: !1,
            showYear: !1,
            shadow: !1,
            showUnit: !1
        }), !1;
        this.setData({
            shadow: !0,
            showCity: !1,
            showYear: !0,
            showUnit: !1
        });
    },
    choose_year: function(t) {
        var e = t.currentTarget.dataset.text, a = t.currentTarget.dataset.index;
        this.setData({
            showCity: !1,
            showYear: !1,
            showUnit: !1,
            shadow: !1,
            year: e,
            yearIndex: a
        }), this.getList();
    },
    bindUnit: function() {
        if (this.data.showUnit) return this.setData({
            showCity: !1,
            showYear: !1,
            shadow: !1,
            showUnit: !1
        }), !1;
        this.setData({
            shadow: !0,
            showCity: !1,
            showYear: !1,
            showUnit: !0
        });
    },
    choose_unit: function(t) {
        var e = t.currentTarget.dataset.text, a = t.currentTarget.dataset.index;
        this.setData({
            showCity: !1,
            showYear: !1,
            showUnit: !1,
            shadow: !1,
            unit: e,
            unitIndex: a
        });
    },
    chooseJob01: function() {
        var e = this;
        wx.request({
            url: t.globalData.request_url + "api/zhiweiku/gk/getSelect.php",
            method: "POST",
            data: {
                act: "getFenlei",
                zwk_sheng: e.data.jgdw_province,
                zwk_diqu: e.data.jgdw_city
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                200 == t.data.code && (e.setData({
                    job_list01: t.data.data,
                    jid01: t.data.data[0]
                }), e.chooseJob02(t.data.data[0]));
            }
        });
    },
    getJobChildren01: function(t) {
        var e = t.currentTarget.dataset.index, a = t.currentTarget.dataset.val;
        this.setData({
            jidActive01: e,
            jid01: a
        }), this.chooseJob02(a);
    },
    chooseJob02: function(e) {
        var a = this;
        wx.request({
            url: t.globalData.request_url + "api/zhiweiku/gk/getSelect.php",
            method: "POST",
            data: {
                act: "getBumen",
                zwk_sheng: a.data.jgdw_province,
                zwk_diqu: a.data.jgdw_city,
                zwk_fenlei: e
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                200 == t.data.code && (a.setData({
                    job_list02: t.data.data,
                    jid02: t.data.data[0]
                }), a.chooseJob03(e, t.data.data[0]));
            }
        });
    },
    getJobChildren02: function(t) {
        var e = t.currentTarget.dataset.index, a = t.currentTarget.dataset.val;
        this.setData({
            jidActive02: e,
            jid02: a
        }), this.chooseJob03(this.data.jid01, a);
    },
    chooseJob03: function(e, a) {
        var i = this;
        wx.request({
            url: t.globalData.request_url + "api/zhiweiku/gk/getSelect.php",
            method: "POST",
            data: {
                act: "getYrsj",
                zwk_sheng: i.data.jgdw_province,
                zwk_diqu: i.data.jgdw_city,
                zwk_fenlei: e,
                zwk_bmmc: a
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                200 == t.data.code && i.setData({
                    job_list03: t.data.data,
                    jid03: t.data.data[0]
                });
            }
        });
    },
    getJobChildren03: function(t) {
        var e = t.currentTarget.dataset.index, a = t.currentTarget.dataset.val;
        this.setData({
            jidActive03: e,
            jid03: a
        });
    },
    job_reset: function() {
        this.setData({
            jid01: "",
            jid02: "",
            jid03: "",
            jidActive01: null,
            jidActive02: null,
            jidActive03: null,
            zwk_fenlei: "",
            zwk_bmmc: "",
            zwk_yrsj: "",
            unit: ""
        }), this.closeLayer(), this.getList();
    },
    city_reset: function() {
        this.setData({
            zwk_sheng: "",
            city: "",
            jid01: "",
            jid02: "",
            jid03: "",
            jidActive01: null,
            jidActive02: null,
            jidActive03: null,
            zwk_fenlei: "",
            zwk_bmmc: "",
            zwk_yrsj: "",
            unit: "",
            job_list01: [],
            job_list02: [],
            job_list03: [],
            jgdw_city: "",
            jgdw_province: ""
        }), this.closeLayer();
        var t = this;
        this.chooseJob01(), t.getList();
    },
    year_reset: function() {
        this.setData({
            year: ""
        }), this.closeLayer(), this.getList();
    },
    chooseJob: function() {
        this.setData({
            zwk_fenlei: this.data.jid01,
            zwk_bmmc: this.data.jid02,
            zwk_yrsj: this.data.jid03,
            page: 1
        }), this.closeLayer();
        var t = this.data.jid03;
        this.setData({
            unit: t
        }), this.getList();
    },
    closeLayer: function() {
        this.setData({
            showCity: !1,
            showYear: !1,
            showUnit: !1,
            shadow: !1,
            showJob: !1,
            showEdu: !1,
            showMajor: !1,
            showMore: !1
        });
    },
    onShareAppMessage: function() {
        return {
            title: "国考小助手",
            path: "/pages/index/index"
        };
    },
    addJob: function(e) {
        var a = this, i = e.currentTarget.dataset.id, s = this.data.list, o = e.currentTarget.dataset.index, n = this.data.arrow_active;
        wx.request({
            url: t.globalData.request_url + "api/zhiweiku/gk/getCollect.php",
            method: "POST",
            data: {
                act: "add_collect",
                openid: wx.getStorageSync("openId"),
                id: i
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                200 == t.data.code ? (wx.showToast({
                    title: "添加成功",
                    icon: "none"
                }), s[n].msg[o].storage_status = 1, a.setData({
                    list: s,
                    collectNum: parseInt(a.data.collectNum) + 1
                })) : wx.showToast({
                    title: t.data.msg,
                    icon: "none"
                });
            }
        });
    },
    delJob: function(e) {
        var a = this, i = e.currentTarget.dataset.id, s = this.data.list, o = e.currentTarget.dataset.index, n = this.data.arrow_active;
        wx.request({
            url: t.globalData.request_url + "api/zhiweiku/gk/getCollect.php",
            method: "POST",
            data: {
                act: "del_collect",
                openid: wx.getStorageSync("openId"),
                id: i
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                200 == t.data.code ? (s[n].msg[o].storage_status = 0, a.setData({
                    list: s,
                    collectNum: parseInt(a.data.collectNum) - 1
                }), wx.showToast({
                    title: "取消成功",
                    icon: "none"
                })) : wx.showToast({
                    title: t.data.msg,
                    icon: "none"
                });
            }
        });
    },
    clear_collect: function() {
        wx.setStorageSync("collectNum", 0), this.setData({
            collectNum: wx.getStorageSync("collectNum")
        });
    }
});